fix: capture OnTrack data on first install without a manual reload - #21
Merged
Conversation
Two gaps left a brand-new install silently empty: - Chrome never runs content_scripts in a tab that was already open before install/update, so a student who had OnTrack open (likely, since that's why they installed the extension) got no capture until they reloaded. Backfill content.js/injected.js into any already-open matching tab from onInstalled via chrome.scripting.executeScript. - The ingest dedup cache marked a payload as "sent" on any resolved JSON response, including a 404 "not subscribed" (ingest fires the moment the content script loads, before the popup's /link-ontrack has created the backend user row) or a `skipped` rejection. Once cached, the identical task data never retried until it changed or the ephemeral service worker restarted. Only cache on genuine success now (2xx + ok:true + no skipped). Bump to 1.13.0 — the scripting permission addition changes what's shown on install/update.
There was a problem hiding this comment.
Pull request overview
This PR updates the Chrome extension so it can start capturing OnTrack data immediately after installation (without requiring the user to manually reload an already-open OnTrack tab) and improves reliability of the background ingest dedup cache by only deduping after confirmed successful storage.
Changes:
- Add
scriptingpermission and backfill-inject the content script into any already-open OnTrack tabs on install. - Harden
/ingestdedup caching to only mark a payload as sent on confirmed success (HTTP 2xx+ok: true+ notskipped). - Bump extension version to
1.13.0.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| extension/public/manifest.json | Bumps version and adds scripting permission needed for runtime injection. |
| extension/public/background.js | Injects content script into already-open OnTrack tabs on install and tightens ingest dedup success criteria. |
| extension/package.json | Bumps extension package version to 1.13.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
25
| chrome.runtime.onInstalled.addListener(async () => { | ||
| let tabs; | ||
| try { | ||
| tabs = await chrome.tabs.query({ url: "https://ontrack.deakin.edu.au/*" }); | ||
| } catch { | ||
| return; // host permission not yet granted or tabs API unavailable | ||
| } | ||
| for (const tab of tabs) { | ||
| if (!tab.id) continue; | ||
| chrome.scripting | ||
| .executeScript({ target: { tabId: tab.id }, files: ["config.js", "content.js"] }) | ||
| .catch(() => {}); // e.g. a chrome:// or restricted tab matched unexpectedly | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
content.js/injected.jsinto any already-open OnTrack tab on install/update viachrome.scripting.executeScript(newscriptingpermission) — Chrome never retroactively injectscontent_scriptsinto tabs opened before the extension was installed, so a student who already had OnTrack open got no capture until they manually reloaded.2xx+ok: true+ noskipped) instead of on any resolved JSON body — a 404"not subscribed"(ingest fires the moment the content script loads, before the popup's/link-ontrackhas created the backend user row) was being cached as if it had landed, so the same task data never retried until it changed or the service worker restarted.1.13.0— the newscriptingpermission changes what's shown on install/update.Test plan
ruff check .passespytestpasses (12 passed) — unaffected backend suite, run as a baseline checknpm run lintpasses inextension/npm run buildsucceeds; verified the builtdist/manifest.jsoncarries the new permission anddist/background.jsmatches the source unmodifiedGenerated by Claude Code